﻿/*
 * Copyright (c) United Binary LLC.  All rights reserved.
 * 
 * This code is licensed under the MIT License
 * 
 * SEE: http://harnessit.codeplex.com/license
 * 
 */
using System;
using System.Collections.Generic;

namespace UnitedBinary.UnitTests.Framework
{
	public class FrameworkExtensions
	{
		static FrameworkExtensions()
		{
			PendingTests = new List<TestExtensionItem>();
		}

		internal static void ClearOpenTests()
		{
			PendingTests.Clear();
		}

		public static void RunAndClearAllOpenTests()
		{
			if ( PendingTests.Count == 0 )
			{
				return;
			}

			PendingTests.FindAll( i => !i.HasRun ).ForEach( i => i.Go() );
			ClearOpenTests();
		}

		internal static List<TestExtensionItem> PendingTests { get; set; }

		internal static void VerifyLastTestWasRun()
		{
			RunAndClearAllOpenTests();
		}
	}
}
